function ac.split(str, p)
	local rt = {}
	str:gsub('[^'..p..']+', function (w)
		table.insert(rt, w)
	end)
	return rt
end

-- 将文本处理成字表
function ac.splittext(text, empty)
    local lenInByte = #text
    local ouputTab = { }
    local i = 1
    while (i <= lenInByte) do
        local curByte = string.byte(text, i)
        local byteCount = 1
        if curByte > 0 and curByte <= 127 then
            byteCount = 1 -- 1字节字符
            -- 要空格这里留下
            if empty or (not empty and curByte ~= 32) then 
                ouputTab[#ouputTab+1] = text:sub( i, i)
            end
        elseif curByte >= 192 and curByte <= 223 then
            byteCount = 2 -- 双字节字符
            ouputTab[#ouputTab+1] = text:sub( i, i + 1)
        elseif curByte >= 224 and curByte <= 239 then
            byteCount = 3 -- 汉字
            ouputTab[#ouputTab+1] = text:sub( i, i + 2)
        elseif curByte >= 240 and curByte <= 247 then
            ouputTab[#ouputTab+1] = text:sub( i, i + 3)
            byteCount = 4 -- 4字节字符
        end
        i = i + byteCount -- 重置下一字节的索引
    end
    return ouputTab
end

--计算2个角度之间的夹角
--	@夹角[0, 180]
--	@旋转方向(1 = 逆时针旋转, -1 = 顺时针旋转)
function ac.math_angle(r1, r2)
	local r = (r1 - r2) % 360
	if r >= 180 then
		return 360 - r, 1
	else
		return r, -1
	end
end
